//
//  HMNaviViewController.m
//  weibo
//
//  Created by apple on 2016/11/12.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "HMNaviViewController.h"
#import "UIBarButtonItem+HMBarButtonItem.h"
#import "HMBaseTableController.h"
@interface HMNaviViewController ()

@end

@implementation HMNaviViewController

- (void)viewDidLoad {
    [super viewDidLoad];

}

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{

    if (self.childViewControllers.count>0) {
        //        UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithImgName:@"navigationbar_back" title:@"返回" action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        viewController.hidesBottomBarWhenPushed = YES;
            UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithImgName:@"navigationbar_back" title:@"返回" Target:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        if ([viewController isKindOfClass:NSClassFromString(@"HMBaseTableController")]) {
            HMBaseTableController *base = (HMBaseTableController*)viewController;
            base.naviItem.leftBarButtonItem = item;
        }else{
            viewController.navigationItem.leftBarButtonItem = item;
        }
    }

    [super pushViewController:viewController animated:animated];
}
-(void)back{
    [self popViewControllerAnimated:YES];
}

@end
